package com.atguigu.gmall.product.controller.api;


import com.atguigu.gmall.model.product.BaseCategory1;
import com.atguigu.gmall.model.product.BaseCategoryView;
import com.atguigu.gmall.model.product.SkuInfo;
import com.atguigu.gmall.model.product.SpuSaleAttr;
import com.atguigu.gmall.product.service.BaseManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/product")
@Api("商品界面")
@Transactional
public class UserInterfaceController {


    @Autowired
    BaseManageService baseManageService;

    //查询页面库存信息
    @ApiOperation("页面库存信息")
    @GetMapping("/inner/getSkuInfo/{skuId}")
    public SkuInfo getSkuInfo(@PathVariable(name = "skuId") Long skuId){
        SkuInfo skuInfo = baseManageService.getSkuInfo(skuId);
        return skuInfo;
    }

    @ApiOperation("查询物品等级列表")
    @GetMapping("/inner/getCategoryView/{category3Id}")
    public BaseCategoryView getCategoryView(@PathVariable(name = "category3Id")Long category3Id){
        BaseCategoryView categoryView = baseManageService.getCategoryView(category3Id);
        return categoryView;
    }

    @ApiOperation("查询商品价格")
    @GetMapping("/inner/getPrice/{skuId}")
    public BigDecimal getPrice(@PathVariable(name = "skuId")Long skuId){
        BigDecimal bigDecimal = baseManageService.getPrice(skuId);
        return bigDecimal;
    }

    @ApiOperation("查询库存销售参数")
    @GetMapping("/inner/getSpuSaleAttrListCheckBySku/{skuId}")
    public List<SpuSaleAttr> getSpuSaleAttrListCheckBySku(
            @PathVariable(name = "skuId") Long skuId
    ){
        List<SpuSaleAttr> saleAttrList = baseManageService.getSpuSaleAttrListCheckBySku(skuId);
        return saleAttrList;
    }

    @ApiOperation("点击其他销售属性值的组合，跳转到另外的sku页面")
    @GetMapping("/inner/getSkuValueIdsMap/{spuId}")
    public Map<String,String> getSkuValueIdsMap(@PathVariable(name = "spuId")Long spuId){
        Map<String,String> stringMap = baseManageService.getSkuValueIdsMap(spuId);
        return stringMap;
    }

    @ApiOperation("首页物品分类")
    @GetMapping("/inner/index")
    public List<BaseCategoryView> getIndex(){
        List<BaseCategoryView> index = baseManageService.getIndex();
        return index;
    }

}
